﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BloomsburyBanHang;
using BloomsburyBanHang.DAO;
namespace BloomsburyBanHang
{
    public partial class shoppingcart : System.Web.UI.Page
    {
        public string chuoiSP;
        public string chuoiCag;
        protected void Page_Load(object sender, EventArgs e)
        {
            string page = Request["page"];
            chuoiSP = "";
            chuoiCag = "";
            chuoiCag += "<a href='#' data-filter='*' class='active'>All</a>";
            string html = "";


            if (page == "author")
            {
                char[] listAH = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H' };
                char[] listIP = { 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P' };
                char[] listQZ = { 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' };
                List<TAC_GIA> DSTacgia = TacGiaDAO.laydsTacGia();
                chuoiCag += "<a href='#' data-filter='.listAH'> A - H </a>";
                chuoiCag += "<a href='#' data-filter='.listIP'> I - P </a>";
                chuoiCag += "<a href='#' data-filter='.listQZ'> Q - Z </a>";
                for (int i = 0; i < DSTacgia.Count; i++)
                {
                    if (listAH.Contains(DSTacgia[i].TenTacGia[0]))
                    {
                        chuoiSP += "<li class='item listAH'>";
                    }
                    else if (listIP.Contains(DSTacgia[i].TenTacGia[0]))
                    {
                        chuoiSP += "<li class='item listIP'>";
                    }
                    else
                    {
                        chuoiSP += "<li class='item listQZ'>";
                    }
                    chuoiSP += "         <a href='#" + DSTacgia[i].MaTacGia + " '><img src='" + DSTacgia[i].HinhAnh + "'/></a>";
                    chuoiSP += "     </li>";

                }

                html = chuoiCag +'~'+chuoiSP;
                Response.Write(html);
                Response.End();
                return;
            }

            List<THE_LOAI> DSTLoai = TheLoaiDAO.LayDSTheLoai();

            for (int i = 0; i < DSTLoai.Count; i++)
            {
                chuoiCag += "<a href='#' data-filter='." + DSTLoai[i].MaTheLoai + "'>" + DSTLoai[i].TenTheLoai + "</a>";
            }
            List<SAN_PHAM> DSSPham = SanPhamDAO.laydsAllSanPham();
            for (int i = 0; i < DSSPham.Count; i++)
            {
                chuoiSP += "<li class='item " + DSSPham[i].MaTheLoai + "'>";
                chuoiSP += "         <span class='price'>" + DSSPham[i].Gia + " €</span>";
                chuoiSP += "         <a href='detail.aspx?MaSanPham=" + DSSPham[i].MaSanPham + " '><img src='" + DSSPham[i].HinhAnh + "'/></a>";
                chuoiSP += "     </li>";
            }

            html = chuoiCag + '~' + chuoiSP;
            Response.Write(html);
            Response.End();

        }
    }
}